package org.jeecg.modules.crm.service.impl;

import org.jeecg.modules.crm.entity.CreditNote;
import org.jeecg.modules.crm.entity.CreditNoteDetailNote;
import org.jeecg.modules.crm.mapper.CreditNoteDetailNoteMapper;
import org.jeecg.modules.crm.mapper.CreditNoteMapper;
import org.jeecg.modules.crm.service.ICreditNoteService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: Credit Note
 * @Author: jeecg-boot
 * @Date:   2025-04-29
 * @Version: V1.0
 */
@Service
public class CreditNoteServiceImpl extends ServiceImpl<CreditNoteMapper, CreditNote> implements ICreditNoteService {

	@Autowired
	private CreditNoteMapper creditNoteMapper;
	@Autowired
	private CreditNoteDetailNoteMapper creditNoteDetailNoteMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		creditNoteDetailNoteMapper.deleteByMainId(id);
		creditNoteMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			creditNoteDetailNoteMapper.deleteByMainId(id.toString());
			creditNoteMapper.deleteById(id);
		}
	}
	
}
